/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package zombieville.GUI;

import zombieville.GUI.TelaMenu;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import zombieville.auxiliares.ApoioImagens;

/**
 *
 * @author Alisson
 */
public class TelaControles extends JPanel {

    private Image imagem;

    public TelaControles(TelaMenu menu) {

        imagem = ApoioImagens.carregaImagem("/Imagens/controles.png");

        MouseListener listener = new ControleMouse(this, menu);
        addMouseListener(listener);

        this.setFocusable(true);
        this.requestFocus();
    }

    public class ControleMouse extends MouseAdapter {

        private int x;
        private int y;
        private TelaMenu menu;
        private TelaControles controles;

        public ControleMouse(TelaControles controles, TelaMenu menu) {
            this.controles = controles;
            this.menu = menu;
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            this.x = e.getX();
            this.y = e.getY();

            System.out.println("CONTROLE: pos x: " + x + "pos y: " + y);

            if ((x > 320 && x < 505) && (y > 354 && y < 393)) {
                controles.setVisible(false);
                menu.setVisible(true);
                menu.requestFocus();
            }

        }
    }

    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);

        g.drawImage(imagem, 0, 0, 800, 600, this);
    }
}
